﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<qlqa.Models.Form.HoaDonForm.HoaDonForm>" %>
<%@ Import Namespace="qlqa.Delegate.FoodDelegate" %>
<%@ Import Namespace="qlqa.Delegate.TableDelegate" %>

<%
    var tableDelegate = new TableDelegate();
    var foodDelegate = new FoodDelegate();
    var hoaDon = Model.HoaDon;
    var res = hoaDon != null ? hoaDon.IsThanhToan : null;
    string trangThai = string.Empty;
    if (res!=null)
    {
        trangThai = res == true ? "Đã thanh toán." : "Chưa thanh toán.";
    }
    string ban = tableDelegate.GetTable(hoaDon!=null ? hoaDon.IdBan : 0).Ten ?? string.Empty;
%>
<input type="hidden" id="IdHoaDon" value="<%= hoaDon!= null ? hoaDon.Id : 0 %>"/>
<div class="row col-md-12">
    <p>Hóa đơn ngày <%= hoaDon != null ? Convert.ToDateTime(hoaDon.NgayTao).ToString("dd/MM/yyyy lúc HH:mm") : string.Empty%></p>
    <p>Tình trạng : <b><%= trangThai %></b></p>
    <p>Bàn : <b><%= ban %></b></p>
</div>
<table class="table table-responsive">
    <thead>
        <th>#</th>
        <th>Món</th>
        <th>SL</th>
        <th>Giá</th>
    </thead>
    <tbody>
    <% if (Model.DanhSachChiTietHoaDon != null)
       {
           if (Model.DanhSachChiTietHoaDon.Any())
           {
               int stt = 1;
               foreach (var item in Model.DanhSachChiTietHoaDon)
               {
                   %>
                   <tr>
                       <td><%= stt++ %></td>
                       <td><%= foodDelegate.GetFoodById(item.IdMon??0).Ten ?? string.Empty %></td>
                       <td><%= item.SoLuong %></td>
                       <td><%= item.GiaThuc %></td>
                   </tr>
                   <%
               }
           }
       } %>
    </tbody>
    
    <tfoot>
        <tr>
            <td colspan="3">Thành tiền</td>
            <td>
                <b><%= hoaDon!=null ? hoaDon.ThanhTien : 0 %></b>
            </td>
        </tr>
    </tfoot>
    
</table>